package com.deng.api.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.deng.api.entity.SysLog;
import com.deng.api.mapper.SysLogMapper;
import com.deng.api.service.ISysLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deng.api.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 系统操作日志表 服务实现类
 * </p>
 *
 * @author deng
 * @since 2022-08-10
 */
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements ISysLogService {
    @Autowired
    private SysLogMapper sysLogMapper;

    @Override
    public PageVO getAll(Integer page, Integer size, SysLog sysLog) {
        Page<SysLog> p = new Page<>(page,size);
        LambdaQueryWrapper<SysLog> wrapper = new LambdaQueryWrapper<>();
        if (sysLog != null && !StrUtil.isEmptyIfStr(sysLog.getDescription())){
            wrapper.like(SysLog::getDescription,sysLog.getDescription());
        }
        Page<SysLog> sysLogPage = sysLogMapper.selectPage(p, wrapper);
        return new PageVO(sysLogPage.getRecords(),sysLogPage.getTotal());
    }
}
